/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package servicos;

import java.util.Date;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import controller.EventosJpaController;
import java.util.GregorianCalendar;

/**
 *
 * @author usuario
 */
@WebService()
public class RestauranteSW {

    /**
     * Operação de serviço web
     */
    @WebMethod(operationName = "buscaEventosEntre")
    public String buscaEventosEntre(@WebParam(name = "idata") String idata, @WebParam(name = "fdata") String fdata) {
        int anoIni = Integer.parseInt(idata.substring(0, 4));
        int mesIni = Integer.parseInt(idata.substring(4, 6))-1;
        int diaIni = Integer.parseInt(idata.substring(6, 8));

        int anoFim = Integer.parseInt(fdata.substring(0, 4));
        int mesFim = Integer.parseInt(fdata.substring(4, 6))-1;
        int diaFim = Integer.parseInt(fdata.substring(6, 8));

        Date dataIni = new GregorianCalendar(anoIni, mesIni, diaIni).getTime();
        Date dataFim = new GregorianCalendar(anoFim, mesFim, diaFim).getTime();

        return new EventosJpaController().findDataEventosEntities(dataIni, dataFim);
    }
}
